package com.example.blog.service.impl;

import com.example.blog.dao.ArticleMapper;
import com.example.blog.model.ArticleInfo;
import com.example.blog.service.IArticleService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.sql.Timestamp;
import java.util.List;

/**
 * @Author YJ
 * @Date 2023/9/5 15:34
 * Description:
 */
@Service
public class IArticleServiceImpl implements IArticleService {

    @Resource
    private ArticleMapper articleMapper;

    @Override
    public List<ArticleInfo> getListById(int userId) {
        return articleMapper.getListById(userId);
    }

    @Override
    public int del(int blogId, int userId) {
        return articleMapper.del(blogId,userId);
    }

    @Override
    public int add(ArticleInfo articleInfo) {
        return articleMapper.add(articleInfo);
    }

    @Override
    public ArticleInfo getArticleByIdAndBlogId(int blogId, int userId) {
        return articleMapper.getArticleByIdAndBlogId(blogId, userId);
    }

    @Override
    public int updateByUserId(int blogId, String title, String content, int userId, Timestamp updateTime) {
        return articleMapper.updateByUserId(blogId,title,content,userId,updateTime);
    }

    @Override
    public ArticleInfo getDetailByBlogId(int blogId) {
        return articleMapper.getDetailByBlogId(blogId);
    }

    @Override
    public int getReadCountByUserId(int userId) {
        return articleMapper.getReadCountByUserId(userId);
    }

    @Override
    public int incrementReadCount(int blogId) {
        return articleMapper.incrementReadCount(blogId);
    }

    @Override
    public List<ArticleInfo> getListByPage(int pSize, int offset) {
        return articleMapper.getListByPage(pSize,offset);
    }

    @Override
    public int getCount() {
        return articleMapper.getCount();
    }


}
